// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import instance from '@/api/index'

import axios from 'axios'
import $ from 'jquery'



/**
 * treeTable组件
 */

import iView from 'iview'
import 'iview/dist/styles/iview.css'    // 使用 CSS
Vue.use(iView)


import VueResource from 'vue-resource'
Vue.use(VueResource)

import ElementUI from 'element-ui';
Vue.use(ElementUI)



// 公共css样式
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/css/bootstrap.css'
import 'font-awesome/css/font-awesome.min.css'
import 'ionicons/dist/css/ionicons.min.css'
import 'bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css'
import 'bootstrap-daterangepicker/daterangepicker.css'
import 'select2/dist/css/select2.min.css'
import 'ionicons/dist/css/ionicons.min.css'
import 'element-ui/lib/theme-chalk/index.css';

//公共js
import './assets/plugins/iCheck/jquery.min'
import './assets/bootstrap/bootstrap.min.js'
// import 'bootstrap/dist/js/bootstrap.min'
import 'jquery-sparkline/jquery.sparkline.min.js'
import 'select2/dist/js/select2.full.min'
import 'moment/moment'
import 'bootstrap-daterangepicker/daterangepicker.js'
import 'bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js'
import 'select2/dist/js/select2.full.min'

import store from './store'

Vue.config.productionTip = false;

/**权限指令**/
Vue.directive('has', {
  bind: function(el, binding) {
    if (!Vue.prototype.$_has(binding.value)) {

    }
  }
});
//权限检查方法
Vue.prototype.$_has = function(value) {
  let isExist=false;
  let buttonpermsStr=sessionStorage.getItem("buttenpremissions");
  if(buttonpermsStr==undefined || buttonpermsStr==null){
    return false;
  }
  let buttonperms=JSON.parse(buttonpermsStr);
  for(let i=0;i<buttonperms.length;i++){
    if(buttonperms[i].perms == value){
      isExist=true;
      break;
    }
  }
  return isExist;
};


new Vue({
  el: '#app',
  store,
  router,
  instance,
  components: { App },
  template: '<App/>'
})
